package com.iplant.basic.serviceImpl.dao.bfc;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.iplant.base.utils.annotation.dao.DBBaseDAO;
import com.iplant.basic.service.po.bfc.BFCHomePageGroup;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.jdbc.core.namedparam.BeanPropertySqlParameterSource;
import org.springframework.jdbc.core.namedparam.SqlParameterSource;
import org.springframework.jdbc.support.GeneratedKeyHolder;
import org.springframework.jdbc.support.KeyHolder;

import com.iplant.base.po.OutResult;
import com.iplant.base.po.Pagination;
import com.iplant.base.po.enums.DBSchemas;
import com.iplant.base.po.enums.ExceptionTypes;
import com.iplant.base.utils.general.StringUtils;
import com.iplant.base.utils.sql.BaseDAO;
import com.iplant.basic.service.po.bfc.BFCHomePageModule;
import com.iplant.basic.service.po.bms.BMSEmployee;

@DBBaseDAO(BFCHomePageModule.class)
public class BFCHomePageModuleDAO extends BaseDAO {

    private static Logger logger = LoggerFactory.getLogger(BFCHomePageModuleDAO.class);

    private static BFCHomePageModuleDAO Instance;

    public List<BFCHomePageModule> SelectAll(BMSEmployee wLoginUser, String wProjectName, int wType, int wUserEnable, int wAdminEnable,int wEngineerEnable,int wSystemEnable,int wActive, String wName,
                                             int wGroupID,
                                             Pagination wPagination, OutResult<Integer> wErrorCode) {

        return this.SelectAll(wLoginUser, wProjectName,  wType, wUserEnable,wAdminEnable,wEngineerEnable,wSystemEnable, wActive, wName, wGroupID, wPagination, wErrorCode);
    }

    public List<BFCHomePageModule> BFC_SelectHomePageModuleAll(BMSEmployee wLoginUser, String wProjectName, int wType,  int wUserEnable, int wAdminEnable,int wEngineerEnable,int wSystemEnable, int wActive, String wName,
                                             int wGroupID,
                                             Pagination wPagination, OutResult<Integer> wErrorCode) {
        Map<String,Object> wParams= new HashMap<>();
        wParams.put("ProjectName",wProjectName);
        wParams.put("Type",wType);
        wParams.put("UserEnable",wUserEnable);
        wParams.put("AdminEnable",wAdminEnable);
        wParams.put("EngineerEnable",wEngineerEnable);
        wParams.put("SystemEnable",wSystemEnable);
        wParams.put("Active",wActive);
        wParams.put("Name",wName);
        wParams.put("GroupID",wGroupID);
        return this.SelectPOList(wLoginUser, wParams, wPagination, wErrorCode);
    }


    public BFCHomePageModule Select(BMSEmployee wLoginUser, int wID, OutResult<Integer> wErrorCode) {


        return this.SelectPO(wLoginUser,wID,"",wErrorCode);
    }

    public int Update(BMSEmployee wLoginUser, BFCHomePageModule wBFCHomePageModule, OutResult<Integer> wErrorCode) {
        int wResult = 0;
        try {
            wErrorCode.set(0);
            wBFCHomePageModule.setUserInfo(wLoginUser);

            wResult= this.UpdatePo(wLoginUser,wBFCHomePageModule,wErrorCode);

        } catch (Exception e) {
            logger.error(e.toString());
            wErrorCode.set(ExceptionTypes.DBSQL.getValue());
        }
        return wResult;
    }

    private BFCHomePageModuleDAO() {
        super("");
        this.Init();
    }

    public static BFCHomePageModuleDAO getInstance() {
        if (Instance == null)
            Instance = new BFCHomePageModuleDAO();
        return Instance;
    }

}
